// pages/group-purchase/purchase.js
import {
  ajax,
  src,
  util
} from "../../utils/util.js";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shoplist:'',
    banners:'',
    circular:true,
    indicatorDots: false,
    autoplay: true,
    interval: 2000,
    duration: 500
  },
  // 跳转搜索
  searchShop:function(){
    wx.navigateTo({
      url: '/pages/search/search'
    })
  },
  // 跳转商品详情
  details:function(e){
    let goodsid = e.currentTarget.dataset.goodsid;
    wx.navigateTo({
      url: '/pages/group-details/details?PTID=' + goodsid,

    })
  },
  // 897团购轮播
  getbanner:function(){
    ajax('/api/Diagram/Get?requestContent=' + JSON.stringify({
      token: wx.getStorageSync("Access_token"),
      ProvinceName: wx.getStorageSync('address_component').province,
      CityName: wx.getStorageSync('address_component').city,
      DistrictName: wx.getStorageSync('address_component').district,
      BroadCastType:2
    }), {
        header: {
          'Accept': 'application/x-www-form-urlencoded', // 默认值
        },
        method: "get",
      }, res => {
        // console.log(res)
        this.setData({
          banners: res.Models
        })
      })
  },
  //897团购数据列表
  getlist:function(){
    ajax('/api/Groupbuying/Get?requestContent=' + JSON.stringify({
      token: wx.getStorageSync("Access_token"),
      ProductName:'',
      ProvinceName: wx.getStorageSync('address_component').province,
      CityName: wx.getStorageSync('address_component').city,
      DistrictName: wx.getStorageSync('address_component').district,
      PageIndex:0
    }), {
        header: {
          'Accept': 'application/x-www-form-urlencoded', // 默认值
        },
        method: "get",
      }, res => {
        // console.log(res)
        this.setData({
          shoplist: res.Models
        })
      })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getbanner();
    this.getlist();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})